﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TRPOP.CMS.Web.UI;

using TRPOP.CMS.Business;
using TRPOP.CMS.Model;
using TRPOP.Common;
using System.Text;

namespace TRPOP.CMS.Web.Admin
{
    public partial class LeftTree : BaseAdmin
    {

        #region 当前页面权限验证
        protected override void SubPageInit()
        {
            //无需特殊的权限
        }
        #endregion

        #region 页面变量
        protected string m_strTitle = "";
        protected string m_strMenu = "";
        protected string m_strView = "";
        protected string m_strJs = "";
        private string m_strXmlType = "";
        NodeManage oNodeManage = new NodeManage();
        string strRootNodeName = SystemInfoHelper.getSystemInfo().RootNodeName;
        #endregion

        #region 页面事件
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Buffer = true;
            Response.ExpiresAbsolute = System.DateTime.Now.AddSeconds(-1);
            Response.Expires = 0;
            Response.CacheControl = "no-cache";
            Response.ClearContent();
            m_strMenu = RequestHelper.RequestString("menu");
            m_strView = RequestHelper.RequestString("view");
            m_strXmlType = RequestHelper.RequestString("xml");
            if (m_strXmlType != "")
            {
                GetNodeChildXml();
            }
            else
            {
                if (!IsPostBack)
                {
                    LoadBase();
                }
            }
        }
        #endregion

        #region 页面方法
        public void LoadBase()
        {
            switch (m_strMenu)
            {
                case "setting_panel":
                    setting_panel.Visible = true;
                    break;
                case "plugin_recomment":
                    tbRecomment.Visible = true;
                    m_strView = m_strMenu;
                    BindTree();
                    break;
                case "plugin_advertisement":
                    tbAdvertisement.Visible = true;
                    m_strView = m_strMenu;
                    break;
                case "tree_panel":
                    tree_panel.Visible = true;
                    BindTree();
                    break;
                case "plugin_contentclick"://信息统计
                    tbContentClick.Visible = true;
                    m_strView = m_strMenu;
                    BindTree();
                    break;
                default:
                    OthersMenu.Visible = true;
                    m_strView = m_strMenu;
                    break;
            }
        }

        /// <summary>
        /// 获取第一级的树
        /// </summary>
        private void BindTree()
        {
            m_strJs = string.Empty;
            StringBuilder strbuilder = new StringBuilder();
            List<NodeInfo> oTempList = oNodeManage.GetListByConditionWithoutUnLinked(0, " and IsHidde=0  and  ParentId=0 ", "   DisplayOrder desc  ,nodeid asc");
            switch (m_strView)
            {
                case "site":
                    #region 站点管理
                    site_js.Visible = true;
                    strbuilder.Append(" var tree = new WebFXTree(\"" + strRootNodeName + "\");\n\t");
                    foreach (NodeInfo oNodeInfo in oTempList)
                    {
                        strbuilder.Append(
                            GetTreeItemJs(
                                         (getNodeChildren(oNodeInfo.NodeId) > 0),
                                         oNodeInfo.NodeTypeId == (int)NodeType.EnumElement.VirualNode,
                                         base.CheckIsHavePermission(oNodeInfo.NodeId),
                                         oNodeInfo.Name,
                                         "LeftTree.aspx?nodeid=" + oNodeInfo.NodeId + "&xml=site_xml",
                                         oNodeInfo.NodeId.ToString(),
                                         "node/Node_save.aspx?nodeid=" + oNodeInfo.NodeId,
                                         true
                            )
                        );

                    }
                    m_strJs += "tree.add(new WebFXLoadTreeItem(\"**回收站**\", \"LeftTree.aspx?nodeid=0&xml=site_recycle_bin_xml\", \"javascript:void(0)\", \"mainwin\", \"recycle_bin\", \"\", \"tree/images/xp/recycle.png\", \"tree/images/xp/recycle.png\"));\t\n";
                    #endregion
                    break;
                case "publish":
                    #region 发布管理
                    publist_js.Visible = true;
                    strbuilder.Append(" var tree = new WebFXTree(\"" + strRootNodeName + "\");\n\t");
                    foreach (NodeInfo oNodeInfo in oTempList)
                    {
                        strbuilder.Append(
                            GetTreeItemJs(
                                         (getNodeChildren(oNodeInfo.NodeId) > 0),
                                         oNodeInfo.NodeTypeId == (int)NodeType.EnumElement.VirualNode,
                                         base.CheckIsHavePermission(oNodeInfo.NodeId),
                                         oNodeInfo.Name,
                                         "LeftTree.aspx?nodeid=" + oNodeInfo.NodeId + "&xml=publish_xml",
                                         oNodeInfo.NodeId.ToString(),
                                         "publish/admin_publish_list.aspx?nodeid=" + oNodeInfo.NodeId,
                                         true
                            )
                        );
                        /* 之前的代码
                        if (getNodeChildren(oNodeInfo.NodeId) > 0)
                        {
                            if (oNodeInfo.NodeTypeId == (int)NodeType.EnumElement.VirualNode)
                            {
                                m_strJs += "tree.add(new WebFXLoadTreeItem(\"" + oNodeInfo.Name + "\", \"LeftTree.aspx?nodeid=" + oNodeInfo.NodeId + "&xml=publish_xml\", \"publish/admin_publish_list.aspx?nodeid=" + oNodeInfo.NodeId + "\", \"mainwin\", \"" + oNodeInfo.NodeId + "\",\"\",\"tree/images/xp/folder_2.png\",\"tree/images/xp/openfolder_2.png\"));";
                            }
                            else
                            {
                                m_strJs += "tree.add(new WebFXLoadTreeItem(\"" + oNodeInfo.Name + "\", \"LeftTree.aspx?nodeid=" + oNodeInfo.NodeId + "&xml=publish_xml\", \"publish/admin_publish_list.aspx?nodeid=" + oNodeInfo.NodeId + "\", \"mainwin\", \"" + oNodeInfo.NodeId + "\"));";
                            }
                        }
                        else
                        {
                            if (oNodeInfo.NodeTypeId == (int)NodeType.EnumElement.VirualNode)
                            {
                                m_strJs += " tree.add(new WebFXTreeItem(\"" + oNodeInfo.Name + "\", \"publish/admin_publish_list.aspx?nodeid=" + oNodeInfo.NodeId + "\", \"mainwin\", \"" + oNodeInfo.NodeId + "\",\"\",\"tree/images/xp/folder_2.png\"));\t\n";
                            }
                            else
                            {
                                m_strJs += " tree.add(new WebFXTreeItem(\"" + oNodeInfo.Name + "\", \"publish/admin_publish_list.aspx?nodeid=" + oNodeInfo.NodeId + "\", \"mainwin\", \"" + oNodeInfo.NodeId + "\"));\t\n";
                            }
                        }
                        */
                    }
                    #endregion
                    break;
                case "node_select":
                    #region 选择结点
                    int intMoveNodeId = RequestHelper.RequestInt("movenodeid");
                    strbuilder.Append(" var tree = new WebFXTree(\"" + strRootNodeName + "\",\"javascript:parent.setTargetNodeID('0')\");\n\t");
                    foreach (NodeInfo oNodeInfo in oTempList)
                    {
                        strbuilder.Append(
                            GetTreeItemJs(
                                         (getNodeChildren(oNodeInfo.NodeId) > 0),
                                         false,
                                         base.CheckIsHavePermission(oNodeInfo.NodeId),
                                         oNodeInfo.Name,
                                         "LeftTree.aspx?nodeid=" + oNodeInfo.NodeId + "&xml=node_select_xml&movenodeid=" + intMoveNodeId,
                                         oNodeInfo.NodeId.ToString(),
                                         "javascript:parent.setTargetNodeID('" + oNodeInfo.NodeId + "')"
                                         , false
                            )
                        );
                        /* 之前的代码
                        if (oNodeInfo.NodeId != intMoveNodeId)
                        {
                            if (getNodeChildren(oNodeInfo.NodeId) > 0)
                            {
                                //m_strJs += "tree.add(new WebFXLoadTreeItem(\"" + oNodeInfo.Name + "\", \"LeftTree.aspx?nodeid=" + oNodeInfo.NodeId + "&xml=publish_xml\", \"admin_publish.aspx?nodeid=" + oNodeInfo.NodeId + "\", \"mainwin\", \"" + oNodeInfo.NodeId + "\"));";
                                m_strJs += "tree.add(new WebFXLoadTreeItem(\"" + oNodeInfo.Name + "\", \"LeftTree.aspx?nodeid=" + oNodeInfo.NodeId + "&xml=node_select_xml&movenodeid=" + intMoveNodeId + "\", \"javascript:parent.setTargetNodeID('" + oNodeInfo.NodeId + "')\" , \"\", \"" + oNodeInfo.NodeId + "\"));";
                            }
                            else
                            {
                                m_strJs += "tree.add(new WebFXTreeItem(\"" + oNodeInfo.Name + "\",\"javascript:parent.setTargetNodeID('" + oNodeInfo.NodeId + "')\" , \"\", \"" + oNodeInfo.NodeId + "\"));";
                            }
                        }*/
                    }
                    #endregion
                    break;
                case "plugin_recomment":
                    #region 评论管理
                    strbuilder.Append(" var tree = new WebFXTree(\"" + strRootNodeName + "\");\n\t");
                    foreach (NodeInfo oNodeInfo in oTempList)
                    {
                        strbuilder.Append(
                            GetTreeItemJs(
                                         (getNodeChildren(oNodeInfo.NodeId) > 0),
                                         false,
                                         base.CheckIsHavePermission(oNodeInfo.NodeId),
                                         oNodeInfo.Name,
                                         "LeftTree.aspx?nodeid=" + oNodeInfo.NodeId + "&xml=recomment_xml",
                                         oNodeInfo.NodeId.ToString(),
                                         "recomment/recomment_list.aspx?nodeid=" + oNodeInfo.NodeId
                                         , true
                            )
                        );
                        /* 之前的代码
                        if (getNodeChildren(oNodeInfo.NodeId) > 0)
                        {
                            m_strJs += " tree.add(new WebFXLoadTreeItem(\"" + oNodeInfo.Name + "\", \"LeftTree.aspx?nodeid=" + oNodeInfo.NodeId + "&xml=recomment_xml\", \"recomment/recomment_list.aspx?nodeid=" + oNodeInfo.NodeId + "\", \"mainwin\", \"" + oNodeInfo.NodeId + "\"));";
                        }
                        else
                        {
                            m_strJs += " tree.add(new WebFXTreeItem(\"" + oNodeInfo.Name + "\", \"recomment/recomment_list.aspx?nodeid=" + oNodeInfo.NodeId + "\", \"mainwin\", \"" + oNodeInfo.NodeId + "\"));\t\n";
                        }
                        */
                    }
                    #endregion
                    break;
                case "plugin_contentclick":
                    #region 信息点击统计
                    strbuilder.Append(" var tree = new WebFXTree(\"" + strRootNodeName + "\");\n\t");
                    foreach (NodeInfo oNodeInfo in oTempList)
                    {
                        strbuilder.Append(
                            GetTreeItemJs(
                                         (getNodeChildren(oNodeInfo.NodeId) > 0),
                                         false,
                                         base.CheckIsHavePermission(oNodeInfo.NodeId),
                                         oNodeInfo.Name,
                                         "LeftTree.aspx?nodeid=" + oNodeInfo.NodeId + "&xml=contentclick_xml",
                                         oNodeInfo.NodeId.ToString(),
                                         "contentclick/ContentClick_list.aspx?nodeid=" + oNodeInfo.NodeId
                                         , true
                            )
                        );
                    }
                    #endregion
                    break;
            }
            m_strJs = strbuilder.ToString();
        }

        /// <summary>
        /// 获取某个节点的子节点
        /// </summary>
        private void GetNodeChildXml()
        {
            Response.ContentType = "text/xml";
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            string strTree = string.Empty;
            StringBuilder strTreeBuild = new StringBuilder();
            int intNid = RequestHelper.RequestInt("nodeid");
            int intMoveNodeId = RequestHelper.RequestInt("movenodeid");
            //string strIcon = "";
            List<NodeInfo> oTempList = null;
            if (m_strXmlType == "site_recycle_bin_xml")
                oTempList = oNodeManage.GetListByConditionWithoutUnLinked(0, " and IsHidde=1 ", "   NodeId asc ");
            else
                oTempList = oNodeManage.GetListByConditionWithoutUnLinked(0, " and IsHidde=0 and  ParentId=" + intNid, "   DisplayOrder desc ,NodeId asc ");
            switch (m_strXmlType)
            {
                case "site_recycle_bin_xml":
                    #region 回收站
                    foreach (NodeInfo oNodeInfo in oTempList)
                    {
                        strTreeBuild.Append(GetTreeItemXML(string.Empty, oNodeInfo.Name,
                            "node/Site_Recycle_Bin.aspx?nodeid=" + oNodeInfo.NodeId,
                            "mainwin", "recycle_bin", oNodeInfo.NodeId.ToString(), string.Empty, oNodeInfo.NodeId));
                        //strTree += "<tree text=\"" + oNodeInfo.Name + "\" action=\"node/Site_Recycle_Bin.aspx?nodeid=" + oNodeInfo.NodeId + "\" cId=\"" + oNodeInfo.NodeId + "\" target=\"mainwin\" extra=\"recycle_bin\"/>";
                    }
                    #endregion
                    break;
                case "site_xml":
                    #region 站点管理
                    foreach (NodeInfo oNodeInfo in oTempList)
                    {
                        strTreeBuild.Append(GetTreeItemXML(
                                             ((oNodeInfo.NodeTypeId == (int)NodeType.EnumElement.VirualNode) ? "tree/images/xp/folder_2.png" : string.Empty),
                                             oNodeInfo.Name,
                                             "node/Node_save.aspx?nodeid=" + oNodeInfo.NodeId,
                                             "mainwin",
                                             string.Empty,
                                             oNodeInfo.NodeId.ToString(),
                                             (getNodeChildren(oNodeInfo.NodeId) > 0) ? "LeftTree.aspx?xml=" + m_strXmlType + "&amp;nodeid=" + oNodeInfo.NodeId : string.Empty
                                             , oNodeInfo.NodeId)
                                             );
                        /*
                        strIcon = "";
                        if (oNodeInfo.NodeTypeId == (int)NodeType.EnumElement.VirualNode)
                        {
                            strIcon = " icon=\"tree/images/xp/folder_2.png\"";
                        }
                        if (getNodeChildren(oNodeInfo.NodeId) > 0)
                        {
                            strTree += "<tree  " + strIcon + " text=\"" + oNodeInfo.Name + "  \" action=\"node/Node_save.aspx?nodeid=" + oNodeInfo.NodeId + "\" src=\"LeftTree.aspx?xml=" + m_strXmlType + "&amp;nodeid=" + oNodeInfo.NodeId + "\" target=\"mainwin\" cId=\" " + oNodeInfo.NodeId + "\"/>";
                        }
                        else
                        {
                            strTree += "<tree  " + strIcon + " text=\"" + oNodeInfo.Name + "  \" action=\"node/Node_save.aspx?nodeid=" + oNodeInfo.NodeId + "\"                                                                                    target=\"mainwin\" cId=\"" + oNodeInfo.NodeId + "\"/>";
                        }
                        */
                    }
                    #endregion
                    break;
                case "publish_xml":
                    #region 发布管理
                    foreach (NodeInfo oNodeInfo in oTempList)
                    {
                        strTreeBuild.Append(GetTreeItemXML(
                                             ((oNodeInfo.NodeTypeId == (int)NodeType.EnumElement.VirualNode) ? "tree/images/xp/folder_2.png" : string.Empty),
                                             oNodeInfo.Name,
                                             "publish/admin_publish_list.aspx?nodeid=" + oNodeInfo.NodeId,
                                             "mainwin",
                                             string.Empty,
                                             oNodeInfo.NodeId.ToString(),
                                             (getNodeChildren(oNodeInfo.NodeId) > 0) ? "LeftTree.aspx?xml=" + m_strXmlType + "&amp;nodeid=" + oNodeInfo.NodeId : string.Empty
                                             , oNodeInfo.NodeId)
                                             );
                        /*
                        strIcon = "";
                        if (oNodeInfo.NodeTypeId == (int)NodeType.EnumElement.VirualNode)
                        {
                            strIcon = " icon=\"tree/images/xp/folder_2.png\"";
                        }
                        if (getNodeChildren(oNodeInfo.NodeId) > 0)
                        {
                            strTree += "<tree " + strIcon + " text=\"" + oNodeInfo.Name + "  \" action=\"publish/admin_publish_list.aspx?nodeid=" + oNodeInfo.NodeId + "\" src=\"lefttree.aspx?xml=" + m_strXmlType + "&amp;nodeid=" + oNodeInfo.NodeId + "\" target=\"mainwin\" cId=\"" + oNodeInfo.NodeId + "\"/>";
                        }
                        else
                        {
                            strTree += "<tree " + strIcon + " text=\"" + oNodeInfo.Name + "  \" action=\"publish/admin_publish_list.aspx?nodeid=" + oNodeInfo.NodeId + "\"                                                                                     target=\"mainwin\" cId=\"" + oNodeInfo.NodeId + "\"/>";
                        }
                        */
                    }
                    #endregion
                    break;
                case "node_select_xml":
                    #region 选择结点
                    foreach (NodeInfo oNodeInfo in oTempList)
                    {
                        if (oNodeInfo.NodeId == intMoveNodeId)
                            continue;
                        strTreeBuild.Append(GetTreeItemXML(
                                             ((oNodeInfo.NodeTypeId == (int)NodeType.EnumElement.VirualNode) ? "tree/images/xp/folder_2.png" : string.Empty),
                                             oNodeInfo.Name,
                                             "javascript:parent.setTargetNodeID('" + oNodeInfo.NodeId + "')",
                                             "",
                                             string.Empty,
                                             oNodeInfo.NodeId.ToString(),
                                             (getNodeChildren(oNodeInfo.NodeId) > 0) ? "LeftTree.aspx?xml=" + m_strXmlType + "&amp;nodeid=" + oNodeInfo.NodeId + "&amp;movenodeid=" + intMoveNodeId : string.Empty
                                             , oNodeInfo.NodeId)
                                             );
                        /*
                        strIcon = "";
                        if (oNodeInfo.NodeTypeId == (int)NodeType.EnumElement.VirualNode)
                        {
                            strIcon = " icon=\"tree/images/xp/folder_2.png\"";
                        }
                        if (oNodeInfo.NodeId != intMoveNodeId)
                        {
                            if (getNodeChildren(oNodeInfo.NodeId) > 0)
                            {
                                strTree += "<tree " + strIcon + " text=\"" + oNodeInfo.Name + "\" action=\"javascript:parent.setTargetNodeID('" + oNodeInfo.NodeId + "')\" src=\"lefttree.aspx?xml=" + m_strXmlType + "&amp;nodeid=" + oNodeInfo.NodeId + "&amp;movenodeid=" + intMoveNodeId + "\" target=\"\" cId=\"" + oNodeInfo.NodeId + "\"/>";
                            }
                            else
                            {
                                strTree += "<tree " + strIcon + " text=\"" + oNodeInfo.Name + "\" action=\"javascript:parent.setTargetNodeID('" + oNodeInfo.NodeId + "')\"                                                                                                                         target=\"\" cId=\"" + oNodeInfo.NodeId + "\"/>";
                            }
                        }
                        */
                    }
                    #endregion
                    break;
                case "recomment_xml":
                    #region 评论
                    foreach (NodeInfo oNodeInfo in oTempList)
                    {
                        strTreeBuild.Append(GetTreeItemXML(
                                             string.Empty,
                                             oNodeInfo.Name,
                                             "recomment/recomment_list.aspx?nodeid=" + oNodeInfo.NodeId,
                                             "mainwin",
                                             string.Empty,
                                             oNodeInfo.NodeId.ToString(),
                                             (getNodeChildren(oNodeInfo.NodeId) > 0) ? "LeftTree.aspx?xml=" + m_strXmlType + "&amp;nodeid=" + oNodeInfo.NodeId : string.Empty
                                             , oNodeInfo.NodeId)
                                             );
                    }
                    #endregion
                    break;
                case "contentclick_xml":
                    #region 信息点击
                    foreach (NodeInfo oNodeInfo in oTempList)
                    {
                        strTreeBuild.Append(GetTreeItemXML(
                                             string.Empty,
                                             oNodeInfo.Name,
                                             "contentclick/ContentClick_list.aspx?nodeid=" + oNodeInfo.NodeId,
                                             "mainwin",
                                             string.Empty,
                                             oNodeInfo.NodeId.ToString(),
                                             (getNodeChildren(oNodeInfo.NodeId) > 0) ? "LeftTree.aspx?xml=" + m_strXmlType + "&amp;nodeid=" + oNodeInfo.NodeId : string.Empty
                                             , oNodeInfo.NodeId)
                                             );
                        /*
                        if (getNodeChildren(oNodeInfo.NodeId) > 0)
                        {
                            strTree += "<tree " + strIcon + " text=\"" + oNodeInfo.Name + "  \" action=\"recomment/recomment_list.aspx?nodeid=" + oNodeInfo.NodeId + "\" src=\"LeftTree.aspx?xml=" + m_strXmlType + "&amp;nodeid=" + oNodeInfo.NodeId + "\" target=\"mainwin\" cId=\" " + oNodeInfo.NodeId + "\"/>";
                        }
                        else
                        {
                            strTree += "<tree " + strIcon + " text=\"" + oNodeInfo.Name + "  \" action=\"recomment/recomment_list.aspx?nodeid=" + oNodeInfo.NodeId + "\"                                                                                    target=\"mainwin\" cId=\"" + oNodeInfo.NodeId + "\"/>";
                        }
                        */
                    }
                    #endregion
                    break;
            }
            if (strTreeBuild.Length > 0)
            {
                Response.Write(strTreeBuild.Insert(0, "<tree> ").Append(" </tree> ").ToString());
            }
            base.End();
        }

        /// <summary>
        /// 获取子节点数量
        /// </summary>
        /// <param name="intNid"></param>
        /// <returns></returns>
        private int getNodeChildren(int intNid)
        {
            List<NodeInfo> Nodelist = new List<NodeInfo>();
            Nodelist = oNodeManage.GetListByConditionWithoutUnLinked(0, " and IsHidde=0  and  ParentId=" + intNid, "   DisplayOrder desc ");
            return Nodelist.Count;
        }

        /// <summary>
        /// BindTree 里对应的方法
        /// </summary>
        /// <param name="IsHaveChild"></param>
        /// <param name="IsVirual"></param>
        /// <param name="IsHavePermission"></param>
        /// <param name="strTreeName"></param>
        /// <param name="strGetChildUrl"></param>
        /// <param name="strParent"></param>
        /// <param name="strActionUrl"></param>
        /// <param name="isTargetMain"></param>
        /// <returns></returns>
        private string GetTreeItemJs(bool IsHaveChild, bool IsVirual, bool IsHavePermission, string strTreeName, string strGetChildUrl, string strParent, string strActionUrl, bool isTargetMain)
        {
            /*
             * WebFXLoadTreeItem(sText,sXmlSrc(获取子节点的url), sActionURL，sAction(例如mainwin),eParent,sIcon,sOpenIcon)
             * 
             * WebFXTreeItem    (sText,                        , sActionURL, sAction(例如mainwin),eParent,sIcon,sOpenIcon);
             */
            string strReturn = string.Empty;
            if (IsHavePermission == false)
                strActionUrl = "javascript:void(0)" + "NoPermission";
            if (IsHaveChild)
            {
                //{0} 名称   {1} 获取子结点的URL
                strReturn = string.Format(" tree.add(new WebFXLoadTreeItem(\"{0}\", \"{1}\", \"{2}\", \"{5}\", \"{3}\"{4})); \t\n"
                    , strTreeName, strGetChildUrl, strActionUrl, strParent, (IsVirual ? ",\"\",\"tree/images/xp/folder_2.png\",\"tree/images/xp/openfolder_2.png\"" : ""), (isTargetMain ? "mainwin" : "")
                          );
            }
            else
            {
                strReturn = string.Format(" tree.add(new WebFXTreeItem(\"{0}\",     \"{1}\",        \"{4}\", \"{2}\"{3}));\t\n "
                    , strTreeName, strActionUrl, strParent, (IsVirual ? ",\"\",\"tree/images/xp/folder_2.png\"" : ""), (isTargetMain ? "mainwin" : "")
                    );
            }
            return strReturn;
        }

        /// <summary>
        /// GetNodeChildXml 对应的方法
        /// </summary>
        /// <param name="strIcon"></param>
        /// <param name="strText"></param>
        /// <param name="strAction"></param>
        /// <param name="strTarget"></param>
        /// <param name="strExtra"></param>
        /// <param name="strCID"></param>
        /// <returns></returns>
        private string GetTreeItemXML(string strIcon, string strText, string strAction, string strTarget, string strExtra, string strCID, string strSrc, int intNodeID)
        {
            StringBuilder strBuilder = new StringBuilder(" <tree  ");

            if (!strIcon.IsEmpty())//可以没有此属性
                strBuilder.Append(" icon=\"" + strIcon + "\" ");

            if (!strText.IsEmpty())
                strBuilder.Append(" text=\"" + strText + "\" ");

            if (!base.CheckIsHavePermission(intNodeID))
                strBuilder.Append(" action=\"javascript:void(0)NoPermission\" ");
            else
            {
                strBuilder.Append(" action=\"" + strAction + "\" ");
            }
            strBuilder.Append(" target=\"" + strTarget + "\" ");//target必须有
            if (!strExtra.IsEmpty())//可以没有
                strBuilder.Append(" extra=\"" + strExtra + "\" ");
            if (!strCID.IsEmpty())
                strBuilder.Append(" cId=\"" + strCID + "\" ");
            if (!strSrc.IsEmpty())//可以没有此属性
                strBuilder.Append(" src=\"" + strSrc + "\" ");
            strBuilder.Append(" />");
            return strBuilder.ToString();
        }

        #endregion
    }
}
